package frame.base;

/**
 * @author PeiWentao
 * ajax提交返回结果
 */
public class Ajax {

    private int code;
    private Object data;
    private String status;
    private String message;

    /**
     * 返回正确结果<br>
     * code = 200 <br>
     * @param data 数据
     * @param message 消息
     * @return
     */
    public static Ajax success(Object data, String message) {
        Ajax ajax = new Ajax();
        ajax.code = 200;
        ajax.data = data;
        ajax.message = message;
        return ajax;
    }

    /**
     * 返回错误结果<br>
     * code=500 <br>
     * date=null <br>
     * @param message 错误消息
     * @return
     */
    public static Ajax faild(String message) {
        return faild(500, null, message);
    }
    /**
     * 返回错误结果<br>
     * code=500 <br>
     * @param data 数据
     * @param message 错误消息
     * @return
     */
    public static Ajax faild(Object data, String message) {
        return faild(500, data, message);
    }
    /**
     * 返回错误结果<br>
     * @param code 错误代码
     * @param data 数据
     * @param message 错误消息
     * @return
     */
    public static Ajax faild(int code, Object data, String message) {
        Ajax ajax =  new Ajax();
        ajax.code = code;
        ajax.data = data;
        ajax.message = message;
        return ajax;
    }

    private Ajax() {
        super();
    }


    public int getCode() {
        return code;
    }
    public void setCode(int code) {
        this.code = code;
    }
    public Object getData() {
        return data;
    }
    public Ajax setData(Object data) {
        this.data = data;
        return this;
    }
    public String getStatus() {
        return status;
    }
    public Ajax setStatus(String status) {
        this.status = status;
        return this;
    }
    public String getMessage() {
        return message;
    }
    public Ajax setMessage(String message) {
        this.message = message;
        return this;
    }
    
    
}
